import TreeNode from "../common/tree_node";
import { n1 } from "../common/tree_node";

//思路：想翻转肯定要遍历，最好理解的就是深度遍历,递归

function invertTree_deep(root: TreeNode | null): TreeNode | null {
    if(root == null) return null//终止条件

    let left = root?.left
    let right = root?.right

    if(left) {
      root.right = invertTree_deep(left)
    }
    if(right) {
      root.left = invertTree_deep(right)
    }
    return root
};

console.log(invertTree_deep(n1))